package cn.edu.sdjzu.xg.eagle.controller;

import cn.edu.sdjzu.xg.eagle.entities.Fees;
import cn.edu.sdjzu.xg.eagle.service.impl.FeesServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.SQLException;
import java.util.List;

@RestController
@RequestMapping("fees")
public class FeesController {

    @Autowired
    private FeesServiceImpl feesService;

    @PostMapping
    public String addFee(@RequestBody Fees fee) throws SQLException {
        return feesService.addFee(fee);
    }

    @DeleteMapping("/{feeId}")
    public String deleteFee(@PathVariable int feeId) throws SQLException {
        return feesService.deleteFee(feeId);
    }

    @PutMapping
    public String updateFee(@RequestBody Fees fee) throws SQLException {
        return feesService.updateFee(fee);
    }

    @GetMapping("/{feeId}")
    public Fees getFee(@PathVariable int feeId) throws SQLException {
        return feesService.findFeeById(feeId);
    }

    @GetMapping
    public List<Fees> getAllFees() throws SQLException {
        return feesService.findAllFees();
    }
}